/*  Copyright 2010 Daniel Brasil Magnani
 *  Created on: Dec 20, 2010
 *      Author: daniel */

#include "constructive.h"
#include "solution.h"

int main(int argc, char* argv[]) {
  if ( argc != 6 ) {
    printf("Execution instructions:\n./run <instance_number> <seed> <time>\n\n");
    printf("<instance_number> Instance number, according to the definition on the instances_map (instances/instances_map) \n");
    printf("<seed> Seed for random numbers \n");
    printf("<time> Seconds that the local searches are going to be executed \n");
    printf("<algorithm>:\n  0- Local Search without DS\n  1- Local Search with DS\n  2- VFLS without DS\n  3- VFLS with DS\n");
    printf("<target/improving> Target to hit on VFLS / Method of improving on the Local Search\n\n");
    exit(0);
  }
  srand(atoi(argv[2]));

//  printf("Initializing instance: %s\n\n", argv[1]);
  Instance::get_instance().Init(argv[1], 1);

  //printf("Creating initial solution...\n\n");
  Constructive constructive;
  constructive.Execute();

  std::vector<Car> car_output;
  car_output = constructive.get_solution();

//  printf("Executing local searches for %s seconds...\n\n", argv[3]);
  Solution solution(car_output);
  switch (atoi(argv[4])) {
    case 0:
      solution.LocalSearch(0, atoi(argv[5]));
      break;
    case 1:
      solution.LocalSearch(1, atoi(argv[5]));
      break;
    case 2:
      solution.VFLS(atoi(argv[3]), 0, atoi(argv[5]));
      break;
    case 3:
      solution.VFLS(atoi(argv[3]), 1, atoi(argv[5]));
      break;
  }
  car_output = solution.get_solution();
//  printf("Writing solution to outputs...\n\n");
  Instance::get_instance().WriteOutput(car_output);
//  printf("Done...\n\n");

  return 0;
}
